package com.yic.module.mes.controller.admin.plan.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import static com.yic.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.yic.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;

@Schema(description = "管理后台 - 生产计划同步 Request VO")
@Data
@ToString(callSuper = true)
public class PlanSyncReqVO {

    @Schema(description = "工厂ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工厂ID不能为空")
    private String factoryId;

    @Schema(description = "工厂代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工厂代码不能为空")
    private String factoryCode;

    @Schema(description = "工厂名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工厂名称不能为空")
    private String factoryName;

    @Schema(description = "工单ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工单ID不能为空")
    private String moId;

    @Schema(description = "工单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工单号不能为空")
    private String code;

    @Schema(description = "单据ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工单ID不能为空")
    private String docId;

    @Schema(description = "单据日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "单据日期不能为空")
    private String docDate;

    @Schema(description = "单据类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "单据类型不能为空")
    private Integer type;

    @Schema(description = "性质", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "单据类型不能为空")
    private Integer nature;

    @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "产品ID不能为空")
    private String itemId;

    @Schema(description = "产品代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "产品代码不能为空")
    private String itemCode;

    @Schema(description = "BOM版次", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "BOM版次不能为空")
    private String bomVersion;

    @Schema(description = "BOM日期", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "BOM日期不能为空")
    private String bomDate;

    @Schema(description = "紧急", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "紧急不能为空")
    private Integer emergent;

    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "状态不能为空")
    private String status;

    @Schema(description = "批工单", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "批工单不能为空")
    private Boolean lotMoFlag;

    @Schema(description = "预计产量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "预计产量不能为空")
    private BigDecimal produceAmount;

    @Schema(description = "申请数量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "申请数量不能为空")
    private BigDecimal reqQty;

    @Schema(description = "批次", requiredMode = Schema.RequiredMode.REQUIRED)
    private String batchNo;

    @Schema(description = "计划开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "计划开始时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private Date planStartTime;

    @Schema(description = "计划完成时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "计划完成时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private Date planCompleteTime;

    @Schema(description = "备注", example = "你说的对")
    private String remark;

    @Schema(description = "工艺管理", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "工艺管理不能为空")
    private Boolean routingControl;

    @Schema(description = "批工单数量", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "批工单数量不能为空")
    private BigDecimal lotMoQty;

    @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "单位不能为空")
    private String unitId;

    @Schema(description = "特征码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "特征码不能为空")
    private String itemFeatureId;

    @Schema(description = "工艺路线号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工艺路线号不能为空")
    private String itemRoutingId;

    @Schema(description = "源工单单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "源工单单号不能为空")
    private String sourceMoId;

    @Schema(description = "母工单单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "母工单单号不能为空")
    private String paraMoId;

    @Schema(description = "生产部门", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "生产部门不能为空")
    private String deptId;

    @Schema(description = "上阶工单单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "上阶工单单号不能为空")
    private String upMoId;

    @Schema(description = "需求单号", requiredMode = Schema.RequiredMode.REQUIRED)
    private String demandNo;

    @Schema(description = "入库仓库", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "入库仓库不能为空")
    private String warehouseId;

    @Schema(description = "入库仓库代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "入库仓库代码不能为空")
    private String warehouseCode;

    @Schema(description = "工作中心", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工作中心不能为空")
    private String centerId;

    @Schema(description = "工作中心代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "工作中心代码不能为空")
    private String centerCode;

    @Schema(description = "总成工单号", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "总成工单号不能为空")
    private String xmoId;

    @Schema(description = "工作中心代码", requiredMode = Schema.RequiredMode.REQUIRED)
    private String xdrawingNo;

    @Schema(description = "单身", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "单身不能为空")
    @Valid
    private List<PlanDSyncReqVO> moDList;



}
